package com.wzq.service.impl;

import com.wzq.pojo.Article;
import com.wzq.repository.ArticleRepository;
import com.wzq.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wzq.Jolin
 * @company none
 * @create 2020-07-24 10:01
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleRepository articleRepository;

    @Override
    public Page< Article > findListByPage(int page, int size) {
        Sort sort = Sort.by(Sort.Direction.DESC, "id");
        Page<Article> pageList = articleRepository.findAll( PageRequest.of(page,size,sort));
        return pageList;
    }
}
